//
//  BaseTableViewCell.m
//  EggSteward
//
//  Created by 王道林 on 16/8/26.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "BaseTableViewCell.h"

@implementation BaseTableViewCell
- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"night" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"day" object:nil];
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUp];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self setUp];
    }
    return self;
}


- (void)setUp
{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor whiteColor];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(night:) name:@"night" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dayTime:) name:@"day" object:nil];
    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
    BOOL is = [userDefault boolForKey:@"night"];
    if (is) {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"night" object:nil userInfo:nil];
    } else
    {
//        [[NSNotificationCenter defaultCenter] postNotificationName:@"day" object:nil userInfo:nil];
    }

}

- (void)night:(NSNotification *)sender
{
    self.contentView.backgroundColor = [UIColor colorWithWhite:0.342 alpha:1.000];
}

- (void)dayTime:(NSNotification *)sender
{
    self.contentView.backgroundColor = [UIColor whiteColor];
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
